
const common = require('../../mixins/common');
const forum = require('../../mixins/forum')
const app = getApp();
import {
  getpdddetail

} from "../../api/common";
const options = {


  /**
   * 页面的初始数据
   */
  data: {
    tags: [],
    currentConfig: {
      show: false,
      transition: true,
      zIndex: 99,
      locked: false,
      direction: 'bottom',
      arcRadius: 18,
      maxHeight: 600,
      minHeight: 600,
      opacity: 0.4
    },
    type:"forums",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      goods_id: options.id
    })
    this.getDateils({
      goods_id: options.id
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  getDateils: function(args) {
    const that=this;
    getpdddetail(args).then(res => {
      console.log(res);
      that.setData({
        goodsInfo: res.goods_detail_response.goods_details[0],
        title: res.goods_detail_response.goods_details[0].goods_name,
        imagesubject: res.goods_detail_response.goods_details[0].goods_gallery_urls,
        textinput: res.goods_detail_response.goods_details[0].goods_desc
      })
    })
  },

  onTagClick: function () {
    wx.navigateTo({
      url: '/pages/creat/tags?tags=' + JSON.stringify(this.data.tags)
    })
  },

  
  onTopicClick: function () {
    wx.navigateTo({
      url: '/pages/creat/circle',
    })

  },

  
  onLocationClick: function () {
    var t = this;
    this.checkPermission("scope.userLocation", "请到设置页面授权“位置信息”权限", function () {
      t.startChooseLocation();
    });
  },

  

  startChooseLocation: function () {
    var t = this;
    wx.chooseLocation({
      success: function (a) {
        t.setData({
          location: {
            latitude: a.latitude,
            longitude: a.longitude,
            address: a.address,
            name: a.name
          }
        });
      }
    });
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
}

common(options)
forum(options)
Page(options)
